All Questions
Tagged with sortingtime-limit-exceeded
26 questions
7votes
4answers
1kviews
LeetCode 977: Squares of a sorted array, maintaining non-decreasing order
I tried solving the LeetCode question like many others, trying to incorporate the O(n) time complexity requirement. Squares of a Sorted Array Given an integer array ...
2votes
1answer
87views
Sort array of numbers using tree sort - Leetcode 912
Problem statement: Sort integer array nums in O(N log N) time, without relying on any library sort routine. I am trying to use a tree sort method (using the ...
5votes
3answers
891views
Counting swaps in a sequence sorting algorithm
I have been working on this question, https://open.kattis.com/problems/sequences. You are given a sequence, in the form of a string with characters ‘0’, ‘1’, and ‘?’ only. Suppose there are n ‘?’s. ...
6votes
1answer
755views
Timeout Error in Fraudulent Activity Notification HackerRank
I am solving this problem: Fraudulent Activity Notifications on HackerRank. I am done with my code and is working, but it is inefficient as well for very large inputs. I don't know but after all my ...
3votes
3answers
4kviews
New Year Chaos JavaScript, needs to be sped up
Similar to this question but this is for Python Original problem with description on hacker rank I am currently trying to iterate through a large number of arrays and count how many times numbers ...
2votes
1answer
98views
Finding maximum homework grade ECOO 2018
I'm trying to solve ECOO 2018 round 2(regionals) question 2 to prepare for the upcoming contest. Basically, in the question George has to achieve the maximum possible grade by completing the right ...
1vote
2answers
187views
Select nth smallest distinct integer from inputs
Kata in question Given a list of integers, return the nth smallest integer in the list. Only distinct elements should be considered when calculating the answer. n will always be positive (n > 0) ...
5votes
2answers
3kviews
Hackerrank "Almost Equal" solution
I've spent the best part of a day on this question. It is marked as Expert level. There are about fifteen submission test cases and my solution manages to satisfy the first four. However, from there ...
1vote
1answer
344views
Verify that each named sequence is strictly increasing
The master launch sequence consists of several independent sequences for different systems. Your goal is to verify that all the individual system sequences are in strictly increasing order. In other ...
6votes
3answers
43kviews
Minimum number of swaps required to sort the array in ascending order
Here is my problem statement. An excerpt: You are given an unordered array consisting of consecutive integers ∈ [1, 2, 3, ..., n] without any duplicates. You are ...
5votes
3answers
5kviews
Sort characters in a Python string by frequency
I wrote a solution to the leetcode problem Sort characters by frequency and the solution passes 34/35 test cases. On the last test case, there is a "time limit exceeded" error with an input string of ...
6votes
2answers
3kviews
Minimum swaps algorithm terminated due to timeout
I have been trying to solve this question. Given an unordered array consisting of consecutive integers [1, 2, 3, …, n], find the minimum number of two-element swaps to sort the array. I was able ...
6votes
3answers
1kviews
C++ code to read, sort, and write data
I had written code in C++ to create transformation filters to get input, sort (custom_sorting and existing sorting routine) and write the output to stdin and file. When I presented it to my teacher, ...
3votes
1answer
1kviews
Sorting a 2-dimensional array with counting sort
The task I'm solving is: Sort a list by its keys Print out the corresponding values on one line separated by whitespace Replace the values of the first half of the input to "-" Use Counting Sort The ...
4votes
2answers
658views
Counting adjacent swaps to sort an array with 3 different values
This is the Kindergarten Excursion problem from kattis.com: The kindergarten teachers had finally managed to get all the kids in a line for the walk to the bus station and the weekly excursion. What ...